package com.zhaoyh.controller;

import com.alibaba.fastjson.JSON;
import com.zhaoyh.bean.IncomeRecord;
import com.zhaoyh.service.IncomeRecordService;
import com.zhaoyh.util.PoiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class MainController extends BaseController{
    public static final String INDEX = "index";

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("......");
        return innerCreateModelAndView(INDEX);
    }

    @RequestMapping(value = "/resume",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String resume() {
        System.out.print("調用resume");
        Map<String, String> map = new HashMap<String, String>();
        map.put("resume", PoiUtil.readWord(File.separator + "opt" + File.separator +"data" + File.separator + "resume.docx"));
        String json = JSON.toJSONString(map);
        return json;
    }

    @Autowired
    IncomeRecordService incomeRecordService;
}
